package com.example.mypro;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class FoodActivityItem extends Activity {
	private TextView tv_name;
	private TextView tv_distance;
	private TextView tv_tag;
	private TextView tv_district;
	private TextView tv_linkname;
	private TextView tv_linkurl;
	private TextView tv_address;
	private TextView tv_telephone;
	private TextView tv_type;
	private TextView tv_price;
	private TextView tag;
	private TextView linkname;
	private TextView linkurl;
	private TextView price;
	private TextView telephone;
	private int distance;
	private String diString;
	private Intent intent;
	private String test;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.food_item);
		tv_name = (TextView) findViewById(R.id.fd_tv_name);
		tv_address = (TextView) findViewById(R.id.fd_tv_address);
		tv_district = (TextView) findViewById(R.id.fd_tv_district);
		tv_distance = (TextView) findViewById(R.id.fd_tv_distance);
		tv_tag = (TextView) findViewById(R.id.fd_tv_tag);
		tv_price = (TextView) findViewById(R.id.fd_tv_price);
		tv_telephone = (TextView) findViewById(R.id.fd_tv_telephone);
		tv_type = (TextView) findViewById(R.id.fd_tv_type);
		tv_linkname = (TextView) findViewById(R.id.fd_tv_linkname);
		tv_linkurl = (TextView) findViewById(R.id.fd_tv_linkurl);
		tag = (TextView) findViewById(R.id.tag);
		linkurl = (TextView) findViewById(R.id.linkurl);
		linkname = (TextView) findViewById(R.id.linkname);
		price = (TextView) findViewById(R.id.price);
		telephone = (TextView) findViewById(R.id.telephone);
		intent = getIntent();
		tv_name.setText(intent.getStringExtra("name"));
		tv_address.setText(intent.getStringExtra("address"));
		tv_district.setText(intent.getStringExtra("district"));
		distance = intent.getIntExtra("distance", 0);
		diString = String.valueOf(distance);
		tv_distance.setText(diString);
		tv_type.setText(intent.getStringExtra("type"));
		test = intent.getStringExtra("tag");
		if ("".equals(test) || "0".equals(test)) {
			tag.setVisibility(View.INVISIBLE);
		} else {
			tv_tag.setText(test);
		}

		test = intent.getStringExtra("telephone");
		if ("".equals(test) || "0".equals(test)) {
			telephone.setVisibility(View.INVISIBLE);
		} else {
			tv_telephone.setText(test);
		}

		test = intent.getStringExtra("price");
		if ("null".equals(test) || "0".equals(test)) {
			price.setVisibility(View.INVISIBLE);
		} else {
			tv_price.setText(test);
		}

		test = intent.getStringExtra("linkname");
		if ("0".equals(test)) {
			linkname.setVisibility(View.INVISIBLE);
		} else {
			tv_linkname.setText(test);
		}

		test = intent.getStringExtra("linkurl");
		if ("0".equals(test)) {
			linkurl.setVisibility(View.INVISIBLE);
		} else {
			tv_linkurl.setText(test);
		}
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		finish();
	}
}
